package cn.joker.constant;

import lombok.Data;

@Data
public class Result<T> {
    private String code;
    private String msg;
    private T data;
//    private Long total; // 用于分页的总记录数

    // 成功响应
    public static <T> Result<T> success(T data) {
        return new Result<>("200", "success", data, null);
    }

    // 成功响应（带分页）
    public static <T> Result<T> success(T data, Long total) {
        return new Result<>("200", "success", data, total);
    }

    // 错误响应
    public static <T> Result<T> error(String code, String msg) {
        return new Result<>(code, msg, null, null);
    }

    // 构造器
    public Result(String code, String msg, T data, Long total) {
        this.code = code;
        this.msg = msg;
        this.data = data;
//        this.total = total;
    }

}